package com.sunnada.edu.system.pub.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sunnada.edu.system.pub.dao.BaseDaoImpl;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service
public class PubDaoImpl  implements PubDao {
	@Resource
	private SqlSession sqlSession;

	public SqlSession getSqlSession() {
		return sqlSession;
	}

	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}

	public List<?> selectList(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		List<?> list = getSqlSession().selectList("pub_sqlmap.select", param);
		return list;
	}
	
	public int selectListCot(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		List<?> list = getSqlSession().selectList("pub_sqlmap.select", param);
		return list.size();
	}

	public int update(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		return getSqlSession().update("pub_sqlmap.update", param);
	}

	public int insert(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		return getSqlSession().insert("pub_sqlmap.insert", param);
	}

	public int delete(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		return getSqlSession().delete("pub_sqlmap.delete", param);
	}

	public String getRoleSeqId() {
		List list = getSqlSession().selectList("pub_sqlmap.getRoleSeqId", null);
		if (list != null) {
			return ((Map) list.get(0)).get("REC_ID") + "";
		} else {
			return "0";
		}
	}
	@Override
	public String getUserSeqId() {
		List list = getSqlSession().selectList("pub_sqlmap.getUserSeqId", null);
		if (list != null) {
			return ((Map) list.get(0)).get("REC_ID") + "";
		} else {
			return "0";
		}
	}

	
    //系统edu 编码
	@Override
	public String getSystemSeqId() {
		List list = getSqlSession().selectList("pub_sqlmap.getSystemSeqId", null);
		if (list != null) {
			return ((Map) list.get(0)).get("REC_ID") + "";
		} else {
			return "0";
		}
	}
	
	
	
	
	
	
	
	
	public String getOrderId() {
		List list = getSqlSession().selectList("pub_sqlmap.getOrderId", null);
		if (list != null) {
			return ((Map) list.get(0)).get("REC_ID") + "";
		} else {
			return "0";
		}
	}

	
	
	public String getNextSeqId(String seqName) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("seqName", seqName);
		List list = getSqlSession().selectList("pub_sqlmap.getNextSeqId", param);
		if (list != null && list.size() > 0) {
			return ((Map) list.get(0)).get("SEQ") + "";
		} else {
			return "";
		}
	}
	/**
	 * 拼接代码使用
	 * */

	@Override
	public List<?> selectUserTel(HashMap<String, String> params) {
		List<?> list = getSqlSession().selectList("pub_sqlmap.selectUserTel", params);
		return list;
	}

	@Override
	public boolean selectUserMsgcode(HashMap<String, String> param) {
		List list =getSqlSession().selectList("pub_sqlmap.selectUserMsgcode", param);
		if(list!=null&&list.size()>0){
			return true;
		}
		return false;
	}

	@Override
	public List<?> selectUserMsgcodeState(HashMap<String, String> params) {
		List<?> list = getSqlSession().selectList("pub_sqlmap.selectUserMsgcodeState", params);
		return list;
	}


	
}
